// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_ok.java

package oa.messager;

import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_ok extends HttpServlet
{

	public register_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			ServletContext context = session.getServletContext();
			String path = context.getRealPath("/");
			nseer_db_backup1 oa_db = new nseer_db_backup1(dbApplication);
			if (oa_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String messager_type = request.getParameter("messager_type");
				String tool_type = request.getParameter("tool_type");
				String register = request.getParameter("register");
				String register_ID = request.getParameter("register_ID");
				String register_time = request.getParameter("register_time");
				String contents = exchange.toHtmlFCK(request.getParameter("content"));
				for (StringTokenizer tokenTO1 = new StringTokenizer(contents, ", "); tokenTO1.hasMoreTokens();)
				{
					String content = tokenTO1.nextToken();
					if (content.indexOf(">") != -1)
						content = content.substring(content.indexOf(">") + 1);
					if (content.indexOf("<") != -1)
						content = content.substring(0, content.indexOf("<"));
					String sql = (new StringBuilder("select * from oa_messager where content='")).append(content).append("'").toString();
					ResultSet rs = oa_db.executeQuery(sql);
					if (!rs.next())
					{
						String sql1 = (new StringBuilder("insert into oa_messager(register,register_ID,register_time,type,tool_type,content) values('")).append(register).append("','").append(register_ID).append("','").append(register_time).append("','").append(messager_type).append("','").append(tool_type).append("','").append(content).append("')").toString();
						oa_db.executeUpdate(sql1);
					}
				}

				oa_db.commit();
				oa_db.close();
				response.sendRedirect("oa/messager/register_ok_b.jsp");
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
